<?php use_helper('Javascript') ?>

<?php if($categories): ?>
    <?php echo select_tag('category_id[]'
                        , options_for_select($categories)
                        , array('onchange' => 'onCatSelected('. $parentId .', this.value)'))?>
    <div id="child_category_<?php echo $parentId?>">...</div>
<?php else: ?>
    <?php echo __('Enter new category')?> <input type='text' name='caterory_new'>
<?php endif;?>
<script type="text/javascript">
function onCatSelected(id, value)
{
    jQuery.ajax({
        type: "post"
        , data: ({'parent_id' : value })
        , dataType: "html"
        , url: "/public_html/test.php/category/getcat"
        , success: function(data) {
            jQuery('#child_category_'+id).html(data);
          }
    });
}
</script>